package com.xinnet.mms.resources.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xinnet.core.dao.impl.BaseDaoImpl;
import com.xinnet.mms.entity.Resources;
import com.xinnet.mms.resources.dao.ResourcesDao;
@Repository("resourcesDao")
public class ResourcesDaoImpl extends BaseDaoImpl<Resources, Long> implements ResourcesDao{
	
	public List<Resources> getResourcesListByRoleId(String roleId){
		List<Resources> resourcesList = super.getSqlSession().selectList("Resources.getResourcesIdListByRoleId",roleId);
		if(resourcesList!=null && resourcesList.size()==0){
			resourcesList = null;
		}
		return resourcesList;
		
	}
	
	public List<Resources> getResourcesList(){
		List<Resources> resourcesList = super.getSqlSession().selectList("Resources.getResourcesList");
		if(resourcesList!=null && resourcesList.size()==0){
			resourcesList = null;
		}
		return resourcesList;
	}
	
	public List<Resources> getResourcesListByRoleIdAndParentId(String roleId,String parentId){
		Resources resources = new Resources();
		resources.setParentId(Integer.parseInt(parentId));
		resources.setRoleId(roleId);
		List<Resources> resourcesList = super.getSqlSession().selectList("Resources.getResourcesListByRoleIdAndParentId",resources);
		if(resourcesList!=null && resourcesList.size()==0){
			resourcesList = null;
		}
		return resourcesList;
		
	}
	public List<Resources> getMenuTreeListByRoleId(String roleId){
		List<Resources> resourcesList = super.getSqlSession().selectList("Resources.getMenuTreeListByRoleId",roleId);
		if(resourcesList!=null && resourcesList.size()==0){
			resourcesList = null;
		}
		return resourcesList;
	}
}
